//
//  LZBaseModel.swift
//  halikaPeso
//
//  Created by L-zh on 2024/12/18.
//

import ObjectMapper

struct LZBaseModel<T: Mappable>: Mappable {
    init?(map: Map) {}
    
    var code: Int?
    var msg: String?
    var data: T?
    
    mutating func mapping(map: Map) {
        code <- map["code"]
        msg <- map["msg"]
        data <- map["data"]
    }
}

struct LZBaseListModel<T: Mappable>: Mappable {
    init?(map: Map) {
    }

    mutating func mapping(map: Map) {
        code <- map["code"]
        msg <- map["msg"]
        data <- map["data"]
    }

    var code: Int?
    var msg: String?
    var data: [T]?

//    init(_ jsonData :JSON) {
//        code = jsonData["code"].stringValue
//        msg = jsonData["msg"].stringValue
//        data =  jsonData["data"].arrayObject as? [T]
//    }
}

struct LZBaseResultModel: Mappable {
    init?(map: Map) {
    }

    mutating func mapping(map: Map) {
        code <- map["code"]
        msg <- map["msg"]
        data <- map["data"]
    }

    var code: Int?
    var msg: String?
    var data:Any?
    
}

/// 可cell通配编辑模型
class LZBaseEditModel {
    var leftStr: String?
    var placeholder: String?
    var isUserInteractionEnabled: Bool = true
    var rightStr: String?
    var id: Int?

    var rateValue:String?
    var rateType:Int?
    
    
//    init(leftStr:String?,placeholder:String?,isUserInteractionEnabled:Bool?,rightStr:String?,id:Int?) {
//        self.leftStr = leftStr
//        self.placeholder = placeholder
//        self.isUserInteractionEnabled = isUserInteractionEnabled ?? true
//        self.rightStr = rightStr
//        self.id = id
//    }
}

@objcMembers class LZBaseProductGroupModel: NSObject,Mappable {
    required init?(map: Map) {
        
    }
    
    func mapping(map: Map) {
        id <- map["id"]
        name <- map["name"]
    }
    
    var id:NSNumber?
    var name:String?
    var seleted:Bool = false
    var groupList:[LZBaseProductGroupModel]?
    

}

@objcMembers class LZBaseProductUnitModel:NSObject,Mappable {
    required init?(map: Map) {
        
    }
    
    func mapping(map: Map) {
        id <- map["id"]
        name <- map["name"]
    }
    
    var id:NSNumber?
    var name:String?
}

@objcMembers class LZBaseCustomerLableModel:NSObject,Mappable {
    required init?(map: Map) {
        
    }
    
    func mapping(map: Map) {
        id <- map["id"]
        name <- map["name"]
    }
    
    var id:NSNumber?
    var name:String?
}

@objcMembers class LZBaseProductListModel:NSObject,Mappable {
    required init?(map: Map) {
        
    }
    
    func mapping(map: Map) {
        alias <- map["alias"]
        groupName <- map["groupName"]
        id <- map["id"]
        imgs <- map["imgs"]
        name <- map["name"]
        rateType <- map["rateType"]
        rateValue <- map["rateValue"]
        shearPrice <- map["shearPrice"]
        status <- map["status"]
        storageType <- map["storageType"]
        unitId <- map["unitId"]
        unitName <- map["unitName"]
    }
    
    override class func value(forUndefinedKey key: String) -> Any? {
        return nil
    }
    
   var alias:String?
    var groupName:String?
     var id:NSNumber?
     var imgs:String?
     var name:String?
     var rateType:Int?
     var rateValue:String?
     var shearPrice:Double?
     var status:Int?
    var storageType:Int?
    var unitId:Int?
    var unitName:String?
}

@objcMembers class LZBaseColorListModel:NSObject,Mappable {
    required init?(map: Map) {
        
    }
    
    func mapping(map: Map) {
        id <- map["id"]
        name <- map["name"]
        productId <- map["productId"]
    }
    
    var id:NSNumber?
    var name:String?
    var productId:NSNumber?
}
